package com.efast.dmom.mgmt.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.efast.dmom.mgmt.service.mes.report.EachQualityGateDoorDataService;
import com.efast.dmom.mgmt.service.mes.report.VehicleQualityGateDoorDataService;

/**
 * 当isNow有值的时候，只会对当天的数据进行操作
 * @author Administrator
 *
 */
@Component
@EnableScheduling
public class TimeUtil {
	
	@Autowired
	private EachQualityGateDoorDataService eachQualityGateDoorDataService;
	
	@Autowired
	private VehicleQualityGateDoorDataService vehicleQualityGateDoorDataService;
	
	@Scheduled(cron="0 30 23 ? * *")
//	@Scheduled(fixedRate = 500000)
	@Async
	public void task() {
//		String isNow = null;
		String isNow = "now";
		eachQualityGateDoorDataService.insertEachQualityGateDoorData(isNow);
	}
	
	@Scheduled(cron="0 40 23 ? * *")
//	@Scheduled(fixedRate = 800000)
	@Async
	public void taskByVehicle() {
//		String isNow = null;
		String isNow = "now";
		vehicleQualityGateDoorDataService.insertVehicleQualityGateDoorData(isNow);
	}
    
	
	//这个定时任务是依据task中插入的表数据来控制的
	@Scheduled(cron="0 50 23 ? * *")
//	@Scheduled(fixedRate = 1100000)
	@Async
	public void taskByVehicleFPY() {
//		String isNow = null;
		String isNow = "now";
		vehicleQualityGateDoorDataService.insertVehicleQualityFPYData(isNow);
	}
}
